#ifndef BATCH_H
#define BATCH_H

/*	CLASS:		Batch
	AUTHOR:		Marcelo Y. B. Hossomi
	OBS:		Abstract class

	Contains batch data.
*/

#include "Problem.h"
#include "Instance.h"
#include "Input.h"
#include "Problem.h"
#include "Util.h"

class Batch {
protected:
	Problem	*problem;	// Batch problem
	char	*name;		// Batch name

	char	*outName;	// Output file
	int		instn;		// Number of instances
	int		execn;		// Number of executions (all instances)
	int		cfgn;		// Number of configs (all instances)
	char	**instName;	// Instances names

	bool	ready;		// 'true' if has been loaded successfully

public:

	static const char	*EXT;		// Batches extension
	static const char	*DIR;		// Batches root directory
	static const char	*OUTDIR;	// Results root directory

	Batch();
	~Batch();

	// Load a batch. Uses 'loadConfig'.
	bool load( const char *name, Problem *problem ) throw (NotFound);

	// Execute all configs. Uses 'executeConfig'. Load before calling.
	void executeAll() throw (NotReady);

	// Execute a single config.
	virtual void executeConfig( int c ) = 0;

	// Load a single config.
	virtual bool loadConfig( Input &in, int c ) = 0;

	// Print batch data.
	virtual void print() throw (NotReady) {};

	// Write batch data to a file.
	virtual void write( const char *file ) throw (NotReady) {};

	// Return the batch full path.
	char* getPath();

	// Return the output full path.
	char* getOutPath();

	// Check if batch is ready.
	bool isReady()			{ return ready; }

};

#endif